/**
 * @class   wosh::interfaces::devices::SensorLight
 * @brief   Standard interface of a generic light sensor (device).
 *
 * @ingroup Interfaces
 ****************************************************************************
 * @version 0.8.384 $Id: SensorLight.h 2885 2010-08-10 01:12:38Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/

#ifndef __WOSH_Interfaces_Devices_SensorLight_H__
 #define __WOSH_Interfaces_Devices_SensorLight_H__

 #include <interfaces/Device.h>


namespace wosh {
 namespace interfaces {
  namespace devices {


class SensorLight : public virtual Device
 {
	WOSH_BUNDLE_INTERFACE("wosh::interfaces::devices::SensorLight")

	public:
		///  states of the light
		enum LIGHT_STATE {
			STATE_UNKNOWN		= 0x00,	///< state is unknown, (default during initialization)
			STATE_BRIGHT		= 0x01,	///< light is on (100%)
			STATE_DARK			= 0x02	///< light is on (custom value, used by Dimmer)
		 };

	public:
		/**
		 * @brief  Evaluate if the light state is \c STATE_BRIGHT. Provided for convenience.
		 * @return true if the state is wosh::interfaces::devices::SensorLight::STATE_BRIGHT; false else
		 */
		inline bool isBright() const		{ return (getLightState() == STATE_BRIGHT); }
		/**
		 * @brief  Evaluate if the light state is \c STATE_DARK. Provided for convenience.
		 * @return true if the state is wosh::interfaces::devices::SensorLight::STATE_DARK; false else
		 */
		inline bool isDark() const			{ return (getLightState() == STATE_DARK); }
		/**
		 * @brief   Get light state as a literal string
		 * @return C string represeting the current state
		 * @see     getSwitchStateAsString
		 */
		inline const char* getLightStateAsString() const { return getLightStateAsString(getLightState()); }

/** @name SensorLight Interface
 * @{
 ******************************************************************************/
	public:
		/**
		 * @brief  Evaluate light's state. Implemented by inherited classes.
		 * @return the current state of the light
		 */
		virtual LIGHT_STATE getLightState() const = 0;

//@}
	public:
		/**
		 * @brief   Get light state as a literal string
		 * @param state [in] light state to be retrieved as literal string
		 * @return  passed light state as literal string
		 */
		static const char* getLightStateAsString( LIGHT_STATE state ) {
			switch(state) {
				case STATE_BRIGHT:			return "BRIGHT";
				case STATE_DARK:			return "STATE_DARK";
				case STATE_UNKNOWN:
				default:					return "UNKNOWN";
			 }
		 }
		/**
		 * @brief   Get light state from a literal string
		 * @param state [in] light state as literal string
		 * @return  light state (as enum) associated with the argument 
		 */
		static LIGHT_STATE getLightStateFromString( const char* state ) {
			if ( state == NULL )							return STATE_UNKNOWN;
			else if ( strcmp(state, "BRIGHT") == 0 )		return STATE_BRIGHT;
			else if ( strcmp(state, "DARK") == 0 )			return STATE_DARK;
			return STATE_UNKNOWN;
		 }

	public:
		virtual ~SensorLight() { }

}; // class def

  }; // namespace devices
 }; // namespace interfaces
}; // namespace wosh

#endif //__WOSH_Interfaces_Devices_SensorLight_H__
